package com.ego.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ego.item.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrandMapper extends BaseMapper<Brand> {
    @Insert("insert into tb_category_brand (category_id, brand_id) VALUES (#{cid},#{bid})")
    void insertCategoryBrand(@Param("cid") Long cid, @Param("bid") Long id);

    @Delete("delete from tb_category_brand where brand_id = #{bid}")
    void deleteCategoryBrand(Long bid);

    @Select("SELECT id,`name` FROM tb_brand b,tb_category_brand cb WHERE b.id = cb.brand_id AND category_id = #{cid}")
    List<Brand> selectByCid(Integer cid);
}
